/**
 * Created by Administrator on 2017/11/10 0010.
 */
$(function(){
    var $container = $('#fall-wrap');//瀑布流中的最大容器
    $container.imagesLoaded(function() {
        $container.masonry({
            itemSelector: '.box',//瀑布流中的每个容器
            gutter: 5,//内容块之间的距离是 5 像素
            isAnimated: true //打开动画选项
        });
    });

    $(".btn").click(function (Objcet) {
        var id = $(this).prevAll("input[name=id]").val();
        var voteId = $("#voteId").val();
        var $votes = $(this).closest("a").find("span");
        $.ajax({
            url:"/voteItem/count",
            data:{id:id,voteId:voteId},
            dataType:"json",
            success:function (msg) {
                layer.open({
                    content: msg.message
                    ,skin: 'msg' //弹层显示风格
                    ,time: 2 //2秒后自动关闭
                });
                if (msg.code==1){
                    $votes.text(Number($votes.text())+1);
                }
            },
            error:function () {
                console.log("投票失败！")
            }
        })
    })
});